package com.system.provider;

import com.am.grid.export.RowCallback;
import com.am.ui.grid.AbstractBaseGridProvider;
import com.system.uitls.CommonUtil;
import com.system.uitls.SearchFilter;
import java.sql.SQLException;
import java.util.Map;

public class UserListProvider extends AbstractBaseGridProvider
  implements RowCallback
{
  public String generateSql(Map<String, Object> map)
  {
    StringBuffer sql = new StringBuffer("SELECT id,name,sex,campus,telephone FROM sys_user WHERE 1=1 AND name != 'admin'");

    sql.append(SearchFilter.getSearchSql(map, null));
    setParamMap(map);
    return sql.toString();
  }

  public void extraProcess(Map<String, Object> map)
    throws SQLException
  {
    String value = CommonUtil.nullToEmptyString(map.get("sex"));
    if ("0".equals(value))
    {
      map.put("sex", "男");
    }
    else map.put("sex", "女");
  }
}